package com.junqson.je.recruit.repo;

import com.junqson.je.recruit.model.ApplicationModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @Descriptions
 * @Company
 * @Author Junqson
 * @Date 2020/2/5 23:53
 * @Version 1.0
 */
@Repository
public interface ApplicationRepo extends JpaRepository<ApplicationModel, Integer> {

    ApplicationModel findByApplicationId(Integer applicationId);

    ApplicationModel findByJobIdAndUserId(Integer jobId, Integer userId);

    Page<ApplicationModel> findByUserId(Integer userId, Pageable pageable);

    Page<ApplicationModel> findByJobId(Integer jobId, Pageable pageable);

    Page<ApplicationModel> findByPublisherId(Integer publisherId, Pageable pageable);

    @Query("select resume from ApplicationModel a where a.publisherId = ?1 and a.applicationId = ?2")
    String getResumeByPublisherIdAndApplicationId(Integer publisherId, Integer applicationId);

}
